/**
  @Author : hanxiaodong
*/

package main

import (
	"github.com/hyperledger/fabric/core/chaincode/shim"
	"fmt"
	"github.com/hyperledger/fabric/protos/peer"
)

type MusicChaincode struct {

}

func (t *MusicChaincode) Init(stub shim.ChaincodeStubInterface) peer.Response{

	return shim.Success(nil)
}

func (t *MusicChaincode) Invoke(stub shim.ChaincodeStubInterface) peer.Response{
	// 获取用户意图
	fun, args := stub.GetFunctionAndParameters()

	if fun == "update"{
		return t.update(stub, args)		// 设置审批员
	}else if fun == "register" {
		return t.register(stub, args)		// 注册
	}else if fun == "getUser" {
		return t.getUser(stub, args)		// 查询user
	}else if fun == "report" {
		return t.report(stub, args)		// 举报
	}else if fun == "getUsers" {
		return t.getUsers(stub, args)		// 查询用户,支持富查询
	}else if fun == "approval" {
		return t.approval(stub, args)		// 根据证书编号及姓名查询信息
	}else	if fun == "addEdu"{
		return t.addEdu(stub, args)		// 添加信息
	}else if fun == "queryEduByCertNoAndName" {
		return t.queryEduByCertNoAndName(stub, args)		// 根据证书编号及姓名查询信息
	}else if fun == "queryEduInfoByEntityID" {
		return t.queryEduInfoByEntityID(stub, args)	// 根据身份证号码及姓名查询详情
	}else if fun == "updateEdu" {
		return t.updateEdu(stub, args)		// 根据证书编号更新信息
	}else if fun == "delEdu"{
		return t.delEdu(stub, args)	// 根据证书编号删除信息
	}

	return shim.Error("000:no this method")

}




func main(){
	err := shim.Start(new(MusicChaincode))
	if err != nil{
		fmt.Printf("启动MusicChaincode时发生错误: %s", err)
	}
}
